@echo off
chcp 65001 >nul
echo ========================================
echo    生成 HTTPS 自签名证书
echo ========================================
echo.

echo 正在生成自签名证书...
echo 这可能需要几分钟时间，请耐心等待...
echo.

if not exist "certs" mkdir certs

openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem -days 365 -nodes -subj "/C=CN/ST=Beijing/L=Beijing/O=P2PDesktop/OU=IT/CN=localhost"

if errorlevel 1 (
    echo ❌ 证书生成失败
    echo 请确保已安装 OpenSSL
    echo 下载地址: https://slproweb.com/products/Win32OpenSSL.html
    pause
    exit /b 1
)

echo ✅ 证书生成成功！
echo 📁 证书文件位置: certs/
echo.
echo 现在可以运行 start-server-https.bat 启动 HTTPS 服务器
echo.
pause 